

const app = getApp()
var CONFIG = require("../../../config/config.js");

Page({

  /**
   * 页面的初始数据
   */
  data: {
    tel: '',
    id: '',  //课程id
    data: '',  //查询结果
    status: '',
    msg: '',
    nper_ll: [],
    nper_jn: [],
    show: '',
  },

  singclick(e) {
    console.log(e);
    var that = this;
    var id = e.target.dataset.id;
    wx.navigateTo({
      url: '/pages/student/period/addnewsign?id='+id+'',
    })
  },

  // 点击我的
  studentmy: function () {
    wx.redirectTo({
      url: '/pages/student/mine',
    })
  },

  // 点击选课记录
  studentchoose: function () {
    wx.redirectTo({
      url: '/pages/public/userCourses?user_id=' + app.globalData.uid + '',
    })
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var that = this;
    wx.showLoading({
      title: '加载中~',
      mask: true
    })


    // 获取本地手机号
    wx.getStorage({
      key: 'tel',
      success: function (res) {
        // console.log(res);
        // console.log(res.data);
        that.setData({
          tel: res.data
        })
        that.queryNper(that.data.id, that.data.tel);
      },
      fail: function (res) {
        that.setData({
          tel: ''
        })
        that.queryNper(that.data.id, that.data.tel);
      }
    });

  },

  /**
   * 查询报课信息
   */
  queryNper: function (id, tel) {
    var that = this;
    wx.request({
      url: CONFIG.API_HOST + 'crm/Courseregist/userNperAll',
      data: {
        phone: tel
      },
      header: {
        'ContentType': 'application/json'
      },
      success: function (res) {
        that.setData({
          status: res.data.status,
          msg: res.data.msg
        })
        if (res.data.status == 1001 || res.data.status == '1001') {
          that.setData({
            // data: res.data.data,
            nper_jn: res.data.data,
          })
        }
        wx.hideLoading();
      }
      
    })
  },


  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})